<style>
.product_img img {
	border: solid 3px #fff;
	margin-right: 5px;
}
.product_img img.hover {
	border-color: #ff8800;
}
.product_img img.current {
	border-color: #df0001;
}
</style>
<div class="container bm-page">
  <div class="col-md-8">
    <div class="bm-form-container" >
      <div class="pay-crumbs-box">
        <div class="pay-crumbs">
        	<a rel="nofollow" class="contact_qq" target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=830584&site=qq&menu=yes"></a>
        	<a class="event_rules" target="_blank" href="<?php echo $this->createUrl('/front/article/show', array('id' => 14))?>"></a>
        </div>
      </div>
      <div class="form-box">
        <div class="head"> 
	        <div class="bm-tabs"> 
	            <a href="<?php echo $this->createUrl('paybm') ?>" class="pull-left btn bm-btn"><i class="bm-spt"></i>今日特惠报名</a>
<!--	            <a href="<?php //echo $this->createUrl('paybm', array('position_id' => 9)) ?>" class="pull-left btn bm-btn active"><i class="bm-spt"></i>双11报名</a>-->
	            <div class="clearfix"></div>
	        </div>
        </div>
        <form id="goodsbm" action="" method="post">
          <table class="form">
            <tbody>
              <tr>
                <td class="title"><?php echo CHtml::activeLabel($model, 'detail_url'); ?>：</td>
                <td><input type="text" name="detail_url" class="input input-mid" value="" id="detail_url" placeholder="请填写商品地址，支持淘宝、天猫、京东">
                  <input type="button" class="get-good bm-spt" id="get_good"></td>
              </tr>
              <tr>
                <td class="title"><?php echo CHtml::activeLabel($model, 'goods_name'); ?>：</td>
                <td><input type="text" class="input input-big" name="goods_name" id="goods_name" maxlength="15" placeholder="标题最短不能少于7个，最长不能大于10个"></td>
              </tr>
              <tr>
                <td class="title"><?php echo CHtml::activeLabel($model, 'product_id'); ?>：</td>
                <td><input type="text" class="input input-big" id="product_id" disabled="disabled">
                  <input type="hidden" class="input input-big" name="product_id"></td>
              </tr>
              <tr>
                <td class="title"><?php echo CHtml::activeLabel($model, 'cat_id'); ?>：</td>
                <td><select name="cat_id">
                    <option value="">请选择商品分类</option>
                    <?php echo CategoryModel::model()->htmlCategorySelectOption() ?>
                  </select></td>
              </tr>
              <tr>
                <td class="title"><?php echo CHtml::activeLabel($model, 'p_price'); ?>：</td>
                <td><input type="text" class="input input-sm" id="p_price" disabled="disabled">
                  宝贝原价由系统自动获取，报名时不能修改宝贝原价
                  <input type="hidden" class="input input-sm" name="p_price"></td>
              </tr>
              <tr>
                <td class="title"><?php echo CHtml::activeLabel($model, 'promo_price'); ?>：</td>
                <td><input type="text" class="input input-sm" name="promo_price" id="promo_price"></td>
              </tr>
              <tr>
                <td class="title"><?php echo CHtml::activeLabel($model, 'sales'); ?>：</td>
                <td><input type="text" class="input input-sm" name="sales" id="sales"></td>
              </tr>
              
			  <tr>
                <td class="title">上架时间：</td>
                <td><input style='font:12px/1.5 arial,"Microsoft Yahei","Hiragino Sans GB",sans-serif' type="text" class="input" name="start_time" id="start_time" value="2014-11-11 00:00:00"  readonly></td>
              </tr>
              <tr>
                <td class="title">下架时间：</td>
                <td><input style='font:12px/1.5 arial,"Microsoft Yahei","Hiragino Sans GB",sans-serif' type="text" class="input" name="start_time" id="start_time" value="2014-11-14 00:00:00"  readonly></td>
              </tr>
              
              <tr>
                <td class="title"><?php echo CHtml::activeLabel($model, 'product_img'); ?>：</td>
                <td><input type="text" class="input input-big" name="product_img" id="product_img"  placeholder="http://">
                  <div class="trip">*图片规定尺寸大小300*300，图片使用清新背景图，模特浅底图，除品牌logo以外不能有其他字眼，请按要求来，否则不予通过。</div></td>
              </tr>
              <tr>
                <td class="title"></td>
                <td><div class="product_img"> </div></td>
              </tr>
              <tr>
                <td class="title"><?php echo CHtml::activeLabel($model, 'goods_brief'); ?>：</td>
                <td><textarea name="goods_brief" style=" width:483px; height:100px;" placeholder="商品简介不能少于25个字"></textarea></td>
              </tr>
              <tr>
                <td class="title"></td>
                <td><input type="hidden" name="state" value="" id="state">
                  <input type="hidden" name="city" value="" id="city">
                  <input type="hidden" name="brand_id" value="0" id="brand_id">
                  <input type="hidden" name="commission_rate" id="commission_rate" value="0">
                  <input type="hidden" name="listorder" value="100">
                  <input type="hidden" name="nick" id="nick" value="">
                  <input type="hidden" name="level" id="level" value="1">
                  <input type="hidden" name="item_type" id="item_type" value="0">
                  <input type="hidden" id="credit_score" value="0">
                  <input type="hidden" id="seller_credit_score" value="6">
                  <input type="hidden" name="special_id" value="5">
                  <input type="hidden" name="start_time" value="<?php echo date('Y') ?>-11-1">
                  <!--<input class="bm-btn bm-spt" type="submit" value=""></td>-->
                  <div class="bm-btn-submit" onclick="$('#goodsbm').submit();">去付款</div>
                  <div class="bm-show-label">展示位:&#165 5000/个</div>
              </tr>
            </tbody>
          </table>
        </form>
        <div class="bottom"> 已经有报名的商品，<a href="<?php echo YzwController::U('goods') ?>">点击查询报名情况</a>! </div>
      </div>
    </div>
  </div>
  <?php include $this->getViewFile('statement'); ?>
  <div class="clear"></div>
</div>
<?php include $this->getViewFile('container'); ?>
<script src="<?php echo Yii::app()->params->staticUrl; ?>statics/js/ajaxForm.js"></script>
<link rel="stylesheet" href="<?php echo Yii::app()->params->staticUrl; ?>statics/js/artDialog6/css/ui-dialog.css">
<script src="<?php echo Yii::app()->params->staticUrl; ?>statics/js/artDialog6/js/dialog-min.js"></script> 
<script>
var tips = dialog();
//防止一次提交多条
var locking = false;

function product_img() {
    $('div.product_img img').click(function() {
        $('div.product_img img').removeClass('current');
        $(this).addClass('current');
        $('#product_img').val(this.src);
    });
}

function getInfo() {
    var product_id = $('input[name="detail_url"]').val();
    if (product_id == '') {
        return false;
    }
    tips = dialog({
        fixed: true,
        title: '获取商品信息中...'
    }).show();
    $.getJSON('<?php echo YzwController::U('bm/iteminfo') ?>', {product_id: product_id}, function(data) {
            tips.close();
            if (data.status) {
                $('#detail_url').val(data.detail_url);
                $('#goods_name').val(data.title);
                //原价
                $('#p_price').val(data.p_price);
                $('input[name="p_price"]').val(data.p_price);
                //活动价格
                $('#promo_price').val(data.promo_price);
                //商品ID
                $('#product_id').val(data.product_id);
                $('input[name="product_id"]').val(data.product_id);
                //旺旺
                $('input[name="nick"]').val(data.nick);
                //店铺类型
                $('input[name="item_type"]').val(data.item_type);
                //销量
                $('#sales').val(data.sales);
                //店铺等级
                $('#credit_score').val(data.credit_score);
                //图片
                var imgstr = '';
                if (data.images) {
                    $.each(data.images, function(i, v) {
                        if (i == 0) {
                            $('#product_img').val(v);
                            imgstr += '<img class="current" width="160" height="160" src=' + v + ' />';
                        } else {
                            imgstr += '<img  width="160" height="160"  src=' + v + ' />';
                        }
                    });
                    $('div.product_img').html(imgstr);
                    product_img();
                }
            } else {
                if (data.info) {
                    $('input[name="detail_url"]').val('');
                    alert(data.info);
                }
            }
        });
}
$(function() {
    $('#goodsbm').ajaxForm({
        dataType: 'json',
        beforeSubmit: function(data, obj, es) {
            if (locking) {
                alert('服务器已经在提交中，等待服务器处理结果，请稍后！');
                return false;
            }
            tips = dialog({
                fixed: true,
                title: '提交中...',
                cancelDisplay: false
            }).showModal();
            locking = true;
            return true;
        },
        success: function(data) {
            tips.title('系统提示');
			tips.content(data.info);
			tips.button([{
				value: '确定',
				callback: function () {
					 if (data.status) {
                        $('#goodsbm').clearForm();
                        $('div.product_img').html('');
                        if (data.url) {
                            window.location.href = data.url;
                        }
                    }
					return true;
				},
				autofocus: true
			}]);
            locking = false;
        }
    });
    $('#get_good').click(function() {
        //getInfo();
    });
    $('input[name="detail_url"]').change(function() {
        getInfo();
    });
});
</script>